package com.google.code.virtualhockey.vhx.server.servlet.rest.error

import com.google.code.virtualhockey.vhx.server.servlet.rest.RestCommandException
import com.google.code.virtualhockey.vhx.util.LangUtils
import javax.servlet.http.HttpServletResponse

/**
 * Indicates that the connected user is not authenticated although authentication is required
 * to access a particular server side resource.
 *
 * @param msg arbitrary error message
 * @param urlLogin the URL of the login page (which can be used for user redirection)
 */
class RestNotAuthenticatedException( msg: String, val urlLogin: String ) extends RestCommandException( msg ) {
  override def  getAdditionalResponseAttributes: List[String] = List( LangUtils.toJsonAttribute( "loginUrl", urlLogin ) )
  override val httpStatusCode = HttpServletResponse.SC_UNAUTHORIZED
}
